package com.tianyi.sfzy1.service;

import com.tianyi.sfzy1.domain.Announcement;
import com.tianyi.sfzy1.mapper.AnnouncementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnnouncementService {
    @Autowired
    private AnnouncementMapper announcementMapper;
    //删除公告
    public int deleteAnnouncement(Long id) {
        return announcementMapper.deleteByPrimaryKey(id);
    }
    //批量删除公告
    public int deleteBatch(List<Integer> ids) {
        return announcementMapper.deleteBatch(ids);
    }
    //插入公告
    public int insertAnnouncement(Announcement announcement) {
        return announcementMapper.insertSelective(announcement);
    }
    //修改公告
    public int updateAnnouncement(Announcement announcement) {
        return announcementMapper.updateByPrimaryKeySelective(announcement);
    }
    //    咨询师跟公告表联查
    public List<Announcement> findAnnouncementsByTitleOrConsultant(String title, String consultantRealname) {
        return announcementMapper.selectAnnouncementWithConsultant(title, consultantRealname);
    }
}
